package org.jeecg.modules.gyy.common;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;

/**
 * @Description: 通用工具
 * @author: L
 */
public class CommonUtils {

    /**
     * 校验密码强度
     *
     * @return
     */
    public static boolean verifyThePasswordStrength(String password) {
        Pattern pattern = Pattern.compile("^(?=.*[a-zA-Z])(?=.*\\d)(?=.*[~!@#$%^&*()_+`\\-={}:\";'<>?,./]).{8,}$");
        return pattern.matcher(password).matches();
    }

    /**
     * 校验手机号码
     *
     * @return
     */
    public static boolean mobilePhoneNumberVerification(String phone) {
        Pattern pattern = Pattern.compile("^1[3|4|5|6|7|8|9][0-9]\\d{8}$");
        return pattern.matcher(phone).matches();
    }

    /**
     * 校验qq邮箱号码
     *
     * @return
     */
    public static boolean emailVerification(String email) {
        Pattern pattern = Pattern.compile("^\\d{5,11}@qq\\.(com|cn)$");
        return pattern.matcher(email).matches();
    }

    /**
     * 校验qq邮箱号码
     *
     * @return
     */
    public static boolean qqEmailVerification(String qqEmail) {
        Pattern pattern = Pattern.compile("^[1-9][0-9]{4,}@qq.com$");
        return pattern.matcher(qqEmail).matches();
    }

    /**
     * 时间格式化
     *
     * @return
     */
    public static String formatCreateTime(Date createTime) {
        if (createTime == null) {
            return null;
        }
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return dateFormat.format(createTime);
    }
}

